<?
include("session.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../webkit/utils/jquery.js"></script>
<script type="text/javascript" src="../webkit/grid/import.js"></script>
<script type="text/javascript" src="../webkit/dialog/import.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/>
</head>
<body>


<table width=100% height=100% cellspacing=0 cellpadding=0>
	<tr bgcolor="#eeeeee">
	<form name=f>
	<td height=30>&nbsp;
	客户类型：<select id="client_type" onchange="search()"><option value='0'>-请选择-</option><option value='1'>单次</option><option value='2'>包年</option><option value='3'>VIP</option></select>　
    客户名称：<input type=text id='client_name' size=12>　
    联系电话：<input type=text id='telephone' size=15>　　 
	<input type="button" value="查询" onclick="search()">　
	</td>
	</tr>
	<tr>
	<td>
		<table id="flex1" style="display:none"></table>
	</td>
	</form>
	</tr>
</table>


<script type="text/javascript">
	<?if($_SESSION['is_agent']=='yes') {?>
	var h = window.screen.height-(115+122+100); // 属于嵌入外部url，只能按screen高度大致计算
	<?} else {?>
	var h = parent.document.body.clientHeight-(115+122);
	if(h < 0) h = 'auto'
	<?}?>
	$("#flex1").flexigrid({
		url: 'client_query.php?action=list',
		dataType: 'json',
		colModel : [
			{display: 'ID', name : 'a', width : 30, sortable : false, align: 'center'},
			{display: '客户姓名', name : 'a', width : 200, sortable : false, align: 'center'},
			{display: '联系手机', name : 'a', width : 80, sortable : false, align: 'center'},
			{display: '客户编号', name : 'a', width : 60, sortable : false, align: 'center'},
			{display: '客户类型', name : 'c', width : 50, sortable : false, align: 'center'},
            {display: '联系地址', name : 'c', width : 200, sortable : false, align: 'center'},
			{display: '服务到期', name : 'exp_date', width : 100, sortable : true, align: 'center'},
            {display: '联系电话1', name : 'c', width : 80, sortable : false, align: 'center'},
			{display: '联系电话2', name : 'b', width : 80, sortable : false, align: 'center'},
			{display: '联系电话3', name : 'e', width : 80, sortable : false, align: 'center'},
			{display: '关联工单', name : 'e', width : 50, sortable : false, align: 'center'}
			],
		buttons : [
            {name: '新增', bclass: 'add', onpress : add},     
			{name: '修改', bclass: 'edit', onpress : edit}
			<?if($_SESSION['uid'] == "admin"){?>
			,     
			{name: '删除', bclass: 'del', onpress : del},
			{separator: true},
			{name: '导入', bclass: 'other', onpress : do_import}
			<?}?>
		],
		<?if($_SESSION['is_agent'] == "yes"){?>
		//title : '客户列表',
		<?}?>
		async : true,
		usepager: true,
		useRp: true,
		rp: 15,
		showTableToggleBtn: false,
		width: 'auto',
		height: h,
		resizable : false,
		singleSelect : true
	});

    
    $('#flex1').dblclick( function (e) { 
        select_row_on_dblclick(e);
        edit();
    }); 

   
	<?
	$add_url = "client_panel.php?op=add";
	$edit_url = "client_panel.php?op=edit&id=";
	$del_url = "client_query.php?action=del&id=";
	$dlg_size = "600,260";
	require("grid_common_js.php");
	?>

	function do_import() {
		dlg = new Dialog({ title: '批量批入客户', resizable:false, maximizable:false}).href("client_import.php");
		dlg.show().setSize(500,120).center();	
	}

	function search() { 
		var url = "client_query.php?action=list";
        if($("#client_type").val()!="") {
            url += "&client_type="+ $("#client_type").val();
        }      
         if($("#client_name").val()!="") {
            url += "&client_name="+ encodeURI($("#client_name").val());
        }        
		if($("#telephone").val()!="") {
			url += "&telephone="+ $("#telephone").val();
		}
		$('#flex1').flexOptions({'url': url}).flexReload(); 
	}

</script>
</body>
</html>
